const { PrismaClient } = require('@prisma/client');

const prisma = new PrismaClient();

async function checkDatabase() {
  try {
    console.log('检查数据库连接...');
    
    // 检查用户表
    const users = await prisma.user.findMany({
      select: {
        id: true,
        username: true,
        email: true,
        role: true,
        status: true,
        createdAt: true
      },
      take: 5
    });
    
    console.log('用户数据:', users);
    console.log('用户总数:', users.length);
    
    // 检查分类表
    const categories = await prisma.category.findMany({
      select: {
        id: true,
        name: true,
        slug: true,
        createdAt: true
      },
      take: 5
    });
    
    console.log('分类数据:', categories);
    console.log('分类总数:', categories.length);
    
  } catch (error) {
    console.error('数据库查询失败:', error);
  } finally {
    await prisma.$disconnect();
  }
}

checkDatabase();
